Skip to content

[wrangler] Add bundle sizes to structured output - #14915

Open
longlho wants to merge 2 commits into
cloudflare:mainfrom
perplexityai:codex/wrangler-bundle-size-output
Open

[wrangler] Add bundle sizes to structured output#14915
longlho wants to merge 2 commits into
cloudflare:mainfrom
perplexityai:codex/wrangler-bundle-size-output

Conversation

@longlho

@longlho longlho commented Jul 29, 2026

Copy link
Copy Markdown

wrangler deploy --dry-run currently reports bundle size only through human-formatted console output. CI size gates must regex that text, which is brittle.

This adds exact raw and gzip-compressed byte counts to the existing structured deploy and version-upload output records, including dry runs:

{
  "bundle_size": {
    "raw_bytes": 1234,
    "gzip_bytes": 567
  }
}

The bundle reporter now returns the measurements it already calculates, and deploy helpers pass them to Wrangler's output writer.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this extends Wrangler's existing machine-readable output without changing CLI usage.

Note

This is a contribution from an AI agent: Codex, GPT-5.

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 18b6ef2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@longlho
longlho marked this pull request as ready for review July 29, 2026 16:10
@longlho
longlho requested a review from workers-devprod as a code owner July 29, 2026 16:11
@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team July 29, 2026 16:11
@workers-devprod

workers-devprod commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/tidy-ravens-report.md: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/deploy/deploy.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/deploy/helpers/bundle-reporter.ts: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/deploy/versions-upload.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/build.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/core.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deploy/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/bundle-reporter.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/dev/remote.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/output.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/versions/upload.ts: [@cloudflare/wrangler]

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the nice improvement @longlho 🙂

I just left a small comment, please let me know what you think (besides this the PR looks good to me)

},
modules: CfModule[]
) {
): Promise<BundleSize> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't tike this change at all 😕

we're taking printBundleSize and have it return a value, this doesn't seem right at all to me

also I don't understand the motivation here, instead of augmenting printBundleSize to return a value, why don't you just call getSize(...) when you need these values instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: if you want to avoid computing the sizes more than once, what I'd suggest you to do is to, instead of modifying this function to return values, modify this function to accept the size and gzipSize and print those instead of calling getSize (or have an override that does that).

@longlho

longlho commented Jul 30, 2026

Copy link
Copy Markdown
Author

yup makes sense, I did another pass lmk if this looks better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants